<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc.jsp"></jsp:include>
<meta http-equiv="X-UA-Compatible" content="edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title >医生列表</title>
<script type="text/javascript">
	var dataGrid;
	var departmentTree;
	var errorCode = '${errorCode}';
	$(function() {
		if(errorCode == '0') {
			departmentTree = $('#departmentTree').tree({
				url : '${ctx}/department/listName',
				lines : true,
				onClick : function(node) {
					dataGrid.datagrid('load', {
						departmentId : node.id
					});
				}
			});
			dataGrid = $('#dataGrid').datagrid({
				url : '${ctx}' + '/siteRegister/doctorDataGrid',
				striped : true,
				rownumbers : true,
				pagination : true,
				singleSelect : true,
				idField : 'doctorId',
				sortName : 'id',
				sortOrder : 'asc',
				pageSize : 50,
				pageList : [ 10, 20, 30, 40, 50, 100, 200, 300,
						400, 500 ],
				frozenColumns : [ [ {
					width: '50',
					title: '编号',
					field: 'doctorId',
					sortable: true
				} ]],
				columns :[[{
					width : '100',
					title : '医生姓名',
					field : 'doctorName',
					sortable : true
				}, {
					width : '80',
					title : '科室ID',
					field : 'departmentId',
					hidden : true
				}, {
					width : '80',
					title : '所属科室',
					field : 'departmentName'
				},{
					width : '150',
					title : '（现场挂号）剩余号数',
					field : 'siteRegisterFreeNum'
				}, {
					width : '150',
					title : '（现场挂号）已挂号数',
					field : 'siteRegisteredNum'
				},{
					field : 'action',
					title : '操作',
					width : 100,
					formatter : function(value, row, index) {
						var str = '';
						str += $.formatString('<a href="javascript:void(0)" onclick="register(\'{0}\');" >挂号</a>',row.doctorId);
						return str;
					}
				}] ],
			
			});
		}
	});

	function register(doctorId) {
		var timeSegmentStr = '${msg}';
		parent.$.modalDialog({
			title : '添加',
			width : 500,
			height : 300,
			href : '${ctx}/siteRegister/addPage?doctorId=' + doctorId + "&timeSegmentStr=" + timeSegmentStr,
			buttons : [ {
				text : '挂号',
				handler : function() {
					parent.$.modalDialog.openner_dataGrid = dataGrid;//因为添加成功之后，需要刷新这个dataGrid，所以先预定义好
					var f = parent.$.modalDialog.handler.find('#siteRegisterAddForm');
					f.submit();
				}
			} ]
		});
	}
</script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',fit:true,border:false" title="${msg }">
		<table id="dataGrid" data-options="fit:true,border:false"></table>
	</div>
	<div data-options="region:'west',border:false,split:true" title="科室"
		style="width: 160px; overflow: hidden;">
		<table id="departmentTree"
			style="width: 120px; margin: 10px 10px 10px 10px"></table>
	</div>

</body>
</html>